<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>家长管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			$("#btnExport").click(function(){
				top.$.jBox.confirm("确认要导出用户数据吗？","系统提示",function(v,h,f){
					if(v=="ok"){
						$("#searchForm").attr("action","${ctx}/sys/user/export");
						$("#searchForm").submit();
					}
				},{buttonsFocus:1});
				top.$('.jbox-body .jbox-icon').css('top','55px');
			});
			$("#btnImport").click(function(){
				$.jBox($("#importBox").html(), {title:"导入数据", buttons:{"关闭":true}, 
					bottomText:"导入文件不能超过5M，仅允许导入“xls”或“xlsx”格式文件！"});
			});
		});
		function page(n,s){
			var flag = '${user.delFlag}'
			if(n) $("#pageNo").val(n);
			if(s) $("#pageSize").val(s);
			$("#searchForm").attr("action","${ctx}/sys/user/listHY");
			if(flag == '0')
				$("#searchForm").attr("action","${ctx}/sys/user/listHSZ");
			$("#searchForm").submit();
	    	return false;
	    }
		
		//选为审核通过
		 function shtg(type) {
			var i = 0;
			var cId = "'-1'";
			$("input:checkbox").each(function() {
				if($(this).attr("checked")=='checked'){
					i++;
					cId+=",'"+$(this).val()+"'";
				}
			}); 
			if(i>0){
				$("#btnForm").attr("action","${ctx}/admin/sysRecommended/save?type="+type+"dataId="+cId+"&&url=/admin/houseSellSp");
				$("#btnForm").submit();
				//dialog("选为已下订单",'url:dd_update.jsp?c=1'+cid,'280px','130px','window');
				//setTimeout(shuaxin,2000);
				return true;
			} else {
				$("#note").html("<font color=red>请至少选择一条记录</font>");
				return false;
			}
		};
		
		//清除缓存
		function clearCache(userId){
			//服务预约列表信息
			url = "${ctx}/sys/user/clearCache/id/"+userId;
			$.ajax({
				 type: "get",
				 url: url,
				 dataType : 'json',
				// data: parameter,
				 success: function(data, textStatus){
					alert("同步成功");
				 },
				 complete: function(XMLHttpRequest, textStatus){
				 },
				 error: function(){
				 }
			});
		};
		
		//同步IM
		function regIm(userId){
			//服务预约列表信息
			url = "${ctx}/sys/user/regIm/id/"+userId;
			$.ajax({
				 type: "get",
				 url: url,
				 dataType : 'json',
				// data: parameter,
				 success: function(data, textStatus){
					alert("IM注册成功");
				 },
				 complete: function(XMLHttpRequest, textStatus){
				 },
				 error: function(){
				 }
			});
		};
	</script>
</head>
<body>
	<div id="importBox" class="hide">
		<form id="importForm" action="${ctx}/sys/user/import" method="post" enctype="multipart/form-data"
			class="form-search" style="padding-left:20px;text-align:center;" onsubmit="loading('正在导入，请稍等...');"><br/>
			<input id="uploadFile" name="file" type="file" style="width:330px"/><br/><br/>　　
			<input id="btnImportSubmit" class="btn btn-primary" type="submit" value="   导    入   "/>
			<a href="${ctx}/sys/user/import/template">下载模板</a>
		</form>
	</div>
	<ul class="nav nav-tabs">
		<c:if test="${user.delFlag=='0'}">
			<li class="active"><a href="${ctx}/sys/user/listHSZ">家长列表</a></li>
		</c:if>
		<c:if test="${user.delFlag=='1'}">
			<li class="active"><a href="${ctx}/sys/user/listHY">家长列表</a></li>
			<li><a href="${ctx}/sys/user/formHY">家长添加</a></li>
		</c:if>
	</ul>
	<form:form id="searchForm" modelAttribute="user" action="${ctx}/sys/user/listHY" method="post" class="breadcrumb form-search ">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<sys:tableSort id="orderBy" name="orderBy" value="${page.orderBy}" callback="page();"/>
		<ul class="ul-form">
			<li><label>机构：</label>
				<form:select path="institutionIdP" class="input-xlarge required ">
					<form:options items="${fns:getInstitutionList()}" itemLabel="institutionName" itemValue="id" htmlEscape="false"/>
				</form:select>
			</li>
			<li><label>登录名：</label><form:input path="loginName" htmlEscape="false" maxlength="50" class="input-medium"/></li>
			<li><label>姓&nbsp;&nbsp;&nbsp;名：</label><form:input path="name" htmlEscape="false" maxlength="50" class="input-medium"/></li>
			<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="查询" onclick="return page();"/>
			<li class="clearfix"></li>
		</ul>
	</form:form>
	<sys:message content="${message}"/>
	
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<th class="sort-column account">登录名</th>
		   <th class="sort-column">家长名称</th>
		   <th>电话</th>
		   <th>性别</th>
		   <th>注册时间</th>
		   <th>登录时间</th>
		   <th>操作</th></tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="userSingle">
			<tr>
				<td><a href="${ctx}/sys/user/formHY?id=${userSingle.id}">${userSingle.account}</a></td>
				<td>${userSingle.name}</td>
				<td>${userSingle.phone}</td>
				<td>${userSingle.sex}</td>
				<td>
					<fmt:formatDate value="${userSingle.createDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
				</td>
				<td>
					<fmt:formatDate value="${userSingle.updateDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
				</td>
				<td>
    				<c:if test="${userSingle.delFlag=='0'}">
						<a href="${ctx}/sys/user/formHYDetail?id=${userSingle.id}&&userType=parent">明细</a>
    					<a href="${ctx}/sys/user/updateUser?id=${userSingle.id}&&userType=parent" onclick="return confirmx('确认要还原该用户吗？', this.href)">还原</a>
						<a href="#" onclick="clearCache(${userSingle.id})">清除缓存</a>
    				</c:if>
					<c:if test="${userSingle.delFlag=='1'}">
						<a href="${ctx}/sys/user/formHY?id=${userSingle.id}">修改</a>
    					<a href="${ctx}/sys/user/delete?id=${userSingle.id}&&userType=parent" onclick="return confirmx('确认要删除该用户吗？', this.href)">删除</a>
						<a href="#" onclick="clearCache(${userSingle.id})">清除缓存</a>
						<a href="#" onclick="regIm(${userSingle.id})">注册IM</a>
    				</c:if>
				</td>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>